1 using UnityEngine;
2 using
System.Collections;
3
4 /*
5     All pieces of Detonator inherit
from this.
6 */

7 public
abstract class DetonatorComponent : MonoBehaviour
8 {
9     
public bool on = true;
10     
public bool detonatorControlled = true;
11     
12     
[HideInInspector]
13     
public float startSize = 1f;
14     
public float size = 1f;
15     
16     
public float explodeDelayMin = 0f;
17     
public float explodeDelayMax = 0f;
18     
19     
[HideInInspector]
20     
public float startDuration = 2f;
21     
public float duration = 2f;
22     
23     
[HideInInspector]
24     
public float timeScale = 1f;
25     
26     
[HideInInspector]
27     
public float startDetail = 1f;
28     
public float detail = 1f;
29     
30     
[HideInInspector]
31     
public Color startColor = Color.white;
32     
public Color color = Color.white;
33     
34     
[HideInInspector]
35     
public Vector3 startLocalPosition = Vector3.zero;
36     
public Vector3 localPosition = Vector3.zero;
37     
38     
[HideInInspector]
39     
public Vector3 startForce = Vector3.zero;
40     
public Vector3 force = Vector3.zero;
41     
42     
[HideInInspector]
43     
public Vector3 startVelocity = Vector3.zero;
44     
public Vector3 velocity = Vector3.zero;
45     
46     
public abstract void Explode();
47     
48     
//The main Detonator calls this instead of using Awake() or Start() on subcomponents
49     
//which ensures it happens when we want.
50     
public abstract void Init();
51     
52     
public float detailThreshold;
53     
54     
/*
55         This exists because Detonator makes relative changes
56         to
set values once the game is running, so we need to store their beginning
57         values somewhere to calculate against. An improved design could probably
58         avoid
this.
59     */

60     
public void SetStartValues()
61     {
62         startSize = size;
63         startForce = force;
64         startVelocity = velocity;
65         startDuration = duration;
66         startDetail = detail;
67         startColor = color;
68         startLocalPosition = localPosition;
69     }
70     
71     
//implement functions to find the Detonator on this GO and get materials if they are defined
72     
public Detonator MyDetonator()
73     {
74         Detonator _myDetonator = GetComponent(
"Detonator") as Detonator;
75         
return _myDetonator;
76     }
77 }


Gõ tìm kiếm nhanh...